package com.gitee.neuray.security.generator.factory;

import com.gitee.neuray.security.generator.enums.DataSourceTypeEnum;
import com.gitee.neuray.security.generator.strategy.DataSourceStrategy;
import com.gitee.neuray.security.generator.strategy.MysqlStrategy;
import com.gitee.neuray.security.generator.strategy.OracleStrategy;
import com.gitee.neuray.security.generator.strategy.SQLServerStrategy;

import java.util.Objects;

/**
 * @author: zhhongyu
 * @description: 选择策略工厂
 * @since: Create in 14:50 2020/2/14
 */
public class DataSourceFactory {
    private static DataSourceFactory ourInstance = new DataSourceFactory();

    public static DataSourceFactory getInstance() {
        return ourInstance;
    }

    private DataSourceFactory() {
    }
    public DataSourceStrategy getDataSourceStrategy(String type){
        if(Objects.equals(DataSourceTypeEnum.ORACLE.getValue(),type)){
            return new OracleStrategy();
        }
        if(Objects.equals(DataSourceTypeEnum.MYSQL.getValue(),type)){
            return new MysqlStrategy();
        }
        if(Objects.equals(DataSourceTypeEnum.SQLSERVER.getValue(),type)){
            return new SQLServerStrategy();
        }
        return null;
    }
}
